{% extends "BlackhouseappBluehouseappBundle:layout:layout.html.twig" %}
{% block title %}
    分类管理
{% endblock %}
{% block body -%}
    <div class="page-header">
        <h2>分类管理 <small></small></h2>
    </div>
    <ol class="breadcrumb clearfix">
        <div class="clearfix">
            <div class="pull-left">
                <a href="{{path('admin_category_new')}}"><button class="btn btn-primary">创建</button></a>
            </div>
        </div>
    </ol>


    <table class="table  table-striped table-hover table-condensed">
        <thead>
            <tr>
                <th>分类名称</th>

                <th>显示序号</th>
                <th>状态</th>
                <th>节点</th>
                <th>最后修改时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        {% for entity in entities %}
            <tr>

                <td>
                    <a href="{{ path('admin_category_show', { 'id': entity.id }) }}">
                    {{ entity.name }}
                    </a>
                </td>

                <td>{{ entity.no }}</td>
                <td>
                    {% if entity.enabled %}
                        <span class="label label-success">正常</span>
                    {% else %}
                        <span class="label label-danger">已禁用</span>
                    {% endif %}
                </td>
                <td>
                    {% if entity.nodes %}
                    {% set nodes=entity.nodes %}
                    {% for node in nodes %}
                        {% if node.status %}
                            {% if node.enabled %}
                            {{ node.name }}
                            {% endif %}
                        {% endif %}
                    {% if loop.last %}
                    {% else %}
                        ,
                    {% endif %}

                    {% endfor %}
                    {% endif %}
                </td>
                <td>{% if entity.modified %}{{ entity.modified|date('Y-m-d H:i:s') }}{% endif %}</td>
                <td>
                <ul>

                    <li>
                        <a href="{{ path('admin_category_edit', { 'id': entity.id }) }}">编辑</a>
                    </li>


                    <li>
                        {% if entity.enabled %}
                            <a href="{{path('category_disable',{id:entity.id})}}"
                               onclick="return confirm('您确定禁用{{entity.name}}吗？')">
                                禁用
                            </a>

                        {% else %}
                            <a href="{{path('category_enable',{id:entity.id})}}"
                               onclick="return confirm('您确定启动{{entity.name}}吗？')">
                                启用
                            </a>
                        {% endif %}
                    </li>
                    <li>
                        <a href="{{path('admin_category_delete',{id:entity.id})}}"
                           onclick="return confirm('您确定要删除{{entity.name}}吗？')">
                            删除
                        </a>
                    </li>
                </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>

    </table>
    {{ knp_pagination_render(entities) }}

    {% endblock %}
